home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / coreaids.zip / TEXT_WRT.ASM < prev    next >
Assembly Source File  |  1987-06-25  |  3KB  |  155 lines

  1. ;    DESC:    Writes text to screen                                V1.02
  2. ;    IN:    *{ATTRIB_PAGE} attribute used to display text (00-FFH),
  3. ;         page number to write on (0-3)
  4. ;        *{ROWCOL} row(0-24), col(0-79) row and column to start writing
  5. ;         at.
  6. ;        *{SEG_VAL} segment of text and
  7. ;        *{OFFSET} offset of text
  8. ;        *{END_OFF} offset end text
  9. ;    SAMPLE:    Callm    TEXT_WRT,<PAGE,ROWCOL,SEG_VAL,OFFSET,END_OFF>,
  10. ;    ######################################################################
  11.  
  12. TEXT_WRD Segment Para Public 'DATA'
  13. ATRIB        DB    7
  14. PAGEL        DW    0
  15. LINE        DB    160
  16. TEXT_WRD Ends
  17.  
  18.  
  19.     Extrn    PUSHALL:Near
  20.     Extrn    POPALL:Near
  21.     Extrn    SCRN_TYP:Near
  22.  
  23. TEXT_WRC    Segment
  24.     Assume    CS:TEXT_WRC,DS:TEXT_WRD
  25.     Public    TEXT_WRT
  26.  
  27.                         ;notice.
  28.     DB    'TEXT_WRT - V1.02, Copyright 1987, CoreTechs   ',0DH,0AH
  29.  
  30. TEXT_WRT    Proc    Near            ;load the screen from memory.
  31.  
  32.     Call    PUSHALL                ;save registers.
  33.  
  34.     Mov    AX,TEXT_WRD            ;set up workarea.
  35.     Mov    DS,AX
  36.  
  37.     Call    SCRN_TYP            ;determine color or b&w.
  38.     Pop    BX
  39.  
  40. COLOR:    Mov    AX,4096                ;determine page offset.
  41.  
  42.     Pop    ES                ;recover offset end of text.
  43.     Pop    DX                ;recover offset of text.
  44.     Pop    SI                ;recover segment of text.
  45.     Pop    DI                ;recover row and column.
  46.     Pop    CX                ;recover page number.
  47.  
  48.     Push    ES                ;replace offset end of text.
  49.     Push    DX                ;replace offset of text.
  50.     Push    SI                ;replace segment of text.
  51.     Push    DI                ;replace row and column.
  52.  
  53.     Cmp    CH,0                ;if no attribute is passed
  54.     Jnz    T1                ;in, then set to white on
  55.     Mov    CH,7                ;black.
  56.  
  57. T1:    Mov    ATRIB,CH            ;store attribute if passed.
  58.  
  59.     Mov    CH,0                ;clear attribute.
  60.  
  61.     Mov    PAGEL,CX            ;determine page offset in
  62.     Mul    PAGEL                ;video memory.
  63.  
  64.     Mov    CL,4                ;divide by 16 to get
  65.     Shr    AX,CL                ;segment value
  66.  
  67.     Add    BX,AX
  68.     Mov    ES,BX                ;get absolute segment.
  69.     
  70.     Pop    AX                ;determine offset of
  71.     Mov    BX,AX                ;row, col on screen.
  72.     Xchg    AH,AL
  73.  
  74.     Mov    AH,0                ;find row offset.
  75.     Mul    LINE
  76.  
  77.     Mov    BH,0                ;cloumn offset is twice value
  78.     Shl    BX,1                ;passed in.
  79.  
  80.     Add    AX,BX                ;store total offset into page
  81.     Mov    DI,AX                ;in DI.
  82.  
  83.     Pop    DS                ;segment of text.
  84.     Pop    SI                ;offset of text.
  85.  
  86.     Pop    CX                ;offset of the end of text.
  87.     Sub    CX,SI
  88.  
  89.     Mov    BP,TEXT_WRD            ;prepare for write operation.
  90.  
  91. CONT:    Cmp    DS:WORD PTR[SI],0A0DH        ;skip to new line of screen
  92.     Jz    NEWLN                ;when carriage return found.
  93.  
  94.     Cmp    DI,4096                ;exit if page end is passed.
  95.     Jl    NOTEND
  96.     Jmp    READY
  97.  
  98. NOTEND:    Cld                    ;move text to screen.
  99.     Movs    ES:BYTE PTR[DI],DS:[SI]        ;move text.
  100.     Dec    CX
  101.     Push    SI
  102.     Push    CX
  103.     Push    BP
  104.     Push    DS
  105.     Pop    BP
  106.     Pop    DS
  107.     Mov    SI,OFFSET ATRIB
  108.     Cld
  109.  
  110.     Movs    ES:BYTE PTR[DI],DS:[SI]        ;move attribute.
  111.     Push    BP
  112.     Push    DS
  113.     Pop    BP
  114.     Pop    DS
  115.     Pop    CX
  116.     Pop    SI
  117.     Cmp    CX,0                ;exit when count is done.
  118.     Jz    READY
  119.     Jmp    CONT
  120.  
  121. NEWLN:    Add    SI,2                ;modifications made to account
  122.     Sub    CX,2                ;for extra characters being
  123.     Mov    AX,DI                ;added becuase of CRLF.
  124.  
  125.     Push    BP                ;determine new line info.
  126.     Push    DS
  127.     Pop    BP
  128.     Pop    DS
  129.     Div    LINE
  130.  
  131.     Push    BP
  132.     Push    DS
  133.     Pop    BP
  134.     Pop    DS
  135.     Inc    AL
  136.     Mov    AH,0
  137.     Push    BP
  138.     Push    DS
  139.     Pop    BP
  140.     Pop    DS
  141.     Mul    LINE
  142.     Push    BP
  143.     Push    DS
  144.     Pop    BP
  145.     Pop    DS
  146.     Mov    DI,AX
  147.     Jmp    CONT
  148.  
  149. READY:    Call    POPALL
  150.     Ret
  151.  
  152. TEXT_WRT    Endp
  153. TEXT_WRC    Ends
  154.     End
  155.